import request from '@/utils/request.js'

// 获取文章详情数据

export const getArticleDetailAPI = artId => {
   return request.get(`/v1_0/articles/${artId}`)
}

// 关注作者API
export const followUserApi = (userId) => {
   return request.post('/v1_0/user/followings', {
        target: userId
    })
}

// 取消关注作者的API
export const unfollowUserApi = userId => {
    return request.delete(`/v1_0/user/followings/${userId}`)
}

// 点赞Api
export const addLikeApi = artId => {
    return request.post('/v1_0/article/likings', {
        target: artId
    })
}

// 取消点赞Api
 export const delLikeApi = artId => {
    return request.delete(`/v1_0/article/likings/${artId}`)
}
// 获取文章下评论列表数据的API（artId是文章ID，offset是偏移量，用来获取分页数据）
export const getCmtListAPI = (artId, offset) => {
    return request.get('/v1_0/comments', {
        params: {
            type: 'a',
            source: artId,
            offset
        }
    })
}
// 评论点赞Api,comId 是评论的id
export const addLikeCmtApi = (comId) => {
    return request.post('/v1_0/comment/likings', {
        target: comId
    })
}

// 取消点赞的api
export const delLikeCmtApi = (comId) => {
    return request.delete(`/v1_0/comment/likings/${comId}`)
}

// 发布评论的Api
export const pubCmtApi = (artId, content) => {
    return request.post('/v1_0/comments', {
        target: artId,
        content
    })
}
